<template>
	<view class="ytb_box">
		
		<view class="usdtbox">
			<view class="content">
				<image class="clogo" src='../../../static/user/user5.png' mode=""></image>
				<view class="font-wight-600 " style="font-size: 64rpx;margin: 30rpx 0;">YtoBi</view>
				<view class="fs-36 font-wight-600" style="color: #9395A4;">YTB {{userInfo.ytc_money||'0'}}(数量)</view>
			</view>
			<!-- <view class="flex-sb fs-28 jiage">
				<view>总价格</view>
				<view>$3804.99</view>
			</view> -->
			<!-- 俩按钮 -->
			<view class="btns_box mt-30">
				<view class="anniu" @click="btnChange(1)" :class="btnActive==1?'active':'noactive'">兑换</view>
				<view class="anniu" @click="btnChange(2)" :class="btnActive==2?'active':'noactive'">转账</view>
			</view>
			<!-- 钱包流水 -->
			<view class="liushuibox">
				<view class="fs-34" style="color: #fff;">
					钱包流水
				</view>
				<!-- 列表 -->
				<view class="water_box" v-for="(item,index) in waterList" :key="item.id">
					<!-- 绿色上箭头 -->
					<view v-if="item.pm==0" class="top_box img_box">
						<image class="img_icon" src="/static/images/personCenter/topjiantou.png" mode=""></image>
					</view>
					<!-- 蓝色下箭头 -->
					<view v-else class="bottom_box img_box">
						<image class="img_icon" src="/static/images/personCenter/bottomjiantou.png" mode=""></image>
					</view>
					<view class="right_box">
						<view class="flex-sb fs-28" style="color: #fff;">
							<view class="">{{item.title}}</view>
							<view class="">
								<text>{{item.type==1?'+':'-'}} YTB </text>
								{{item.num}}
							</view>
						</view>
						<view class="flex-sb fs-26" style="color: #9395A4;">
							<view class="">{{times(item.created_at)}}</view>
							<view class="">
								总 : {{item.new_balance}}
							</view>
						</view>
					</view>
				</view>
				<!-- <view class="fs-32 loadmore">
					下滑加载更多
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				btnActive: 1,
				waterList: [{
						id: 1,
						title: 'USDT 兑换 YTB',
						type: 1,
						ustd: '0.0056',
						time: '3/22 19:21:00',
						zong: '950.00'
					},
					{
						id: 2,
						title: '设备产出',
						type: 1,
						ustd: '0.0056',
						time: '3/22 19:21:00',
						zong: '950.00'
					},
					{
						id: 3,
						title: 'YTB转账',
						type: 2,
						ustd: '0.0056',
						time: '3/22 19:21:00',
						zong: '950.00'
					}
				]
			};
		},
		onLoad() {
			this.get_bills()
		},
		methods: {
			times(str){
				let date=new Date( Number(str + '000') )
				const formatNumber = n => {
					n = n.toString()
					return n[1] ? n : '0' + n
				}
				 console.log(str);
				 	 console.log(date);
				const formatTime = (date, word = false, datestring = '/', timestring = ":") => {
					
					const year = date.getFullYear()
					const month = date.getMonth() + 1
					const day = date.getDate()
					const hour = date.getHours()
					const minute = date.getMinutes()
					const second = date.getSeconds()
					// if (word == false) {
					// 	return [year, month, day].map(formatNumber).join(datestring) + ' ' + [hour, minute, second].map(
					// 		formatNumber).join(
					// 		timestring)
					// }
					return [year].map(formatNumber) + '年' + [month].map(formatNumber) + '月' + [day].map(formatNumber) + '日' + ' ' +
						[
							hour
						].map(formatNumber) + ':' + [minute].map(formatNumber) + ':' + [second].map(formatNumber)
				}
				return formatTime(date)
			},
			async get_bills(){
				let res = await this.$http.get('user/get_bills?pay_type=2', {
					
				})
				this.waterList=res.data
			},
			btnChange(num) {
				this.btnActive = num
				if(num==2){
					this.$tools.jumpTo('./ytbtransfer')
				}
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #1E2240;
	}

	.ytb_box {
		.usdtbox {
			padding: 30rpx;

			.liushuibox {
				margin-top: 90rpx;

				.loadmore {
					margin-top: 60rpx;
					text-align: center;
					color: #fff;
				}

				.water_box {
					display: flex;
					align-items: center;
					margin-top: 40rpx;

					.right_box {
						margin-left: 20rpx;
						width: 100%;
						height: 86rpx;
						display: flex;
						flex-direction: column;
						justify-content: space-between;
					}

					.img_box {
						width: 100rpx;
						min-width: 100rpx;
						height: 100rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						border-radius: 50%;

						.img_icon {
							width: 40rpx;
							height: 40rpx;
						}
					}

					.top_box {
						background-color: #1ba27a;
					}

					.bottom_box {
						background-color: #1f78fd;
					}
				}
			}

			.btns_box {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.anniu {
					width: 320rpx;
					height: 110rpx;
					line-height: 110rpx;
					border-radius: 200rpx;
					box-shadow: 0 20rpx 30rpx #191c32;
					text-align: center;
					font-size: 30rpx;
				}

				.active {
					background-color: #6C6AEB;
					color: #fff;
				}

				.noactive {
					color: rgba(118, 125, 255, 1);
					background-color: #303466;
				}
			}

			.jiage {
				color: #94959B;
				padding: 0 50rpx;
				margin: 60rpx auto 90rpx;
			}

			.content {
				margin-top: 40rpx;
				color: #fff;
				display: flex;
				flex-direction: column;
				align-items: center;

				.clogo {
					width: 160rpx;
					height: 160rpx;
					border-radius: 50%;
				}
			}
		}

		
	}
</style>